package com.pai4j.api.controller;


import com.pai4j.api.service.ChatMessageService;
import com.pai4j.common.bean.PAIResponseBean;
import com.pai4j.common.bean.PAIResponseBeanUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/chat/message")
public class ChatMessageController {


    @Autowired
    private ChatMessageService chatMessageService;

    @GetMapping("/query")
    public PAIResponseBean<List<String>> query(@RequestParam String sourceUserId,
                                               @RequestParam String targetUserId,
                                               @RequestParam(required = false) Long startTime,
                                               @RequestParam(required = false) Long endTime,
                                               @RequestParam(required = false, defaultValue = "1000") Integer count) {
        List<String> messages = chatMessageService.query(sourceUserId, targetUserId, startTime, endTime, count);
        return PAIResponseBeanUtil.success(messages);
    }


}
